<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <!--  循环任务-关联选中状态-铺设数据 -->
    <li :class="{ completed:item.isDone}" v-for="item in list" :key="item.id">
      <div class="view">
        <input class="toggle" type="checkbox" @change="changeFn(item.id)" :checked="item.isDone"/>
        <label>{{ item.name }}</label>
        <button class="destroy" @click="del(item.id)"></button>
      </div>
    </li>
  </ul>
  
</template>

<script>
export default {
  //props: ['list]
  props: {
    list:{
      type:Array,
      required: true
    }
  },
  methods:{
    del(id){
        //删除list 里面的数据
    // console.log(id);
     // 子传父
    this.$emit('del',id)
  },
  changeFn(id){
this.$emit('change',id)
  }
  },

}
</script>